import request from '@/utils/request.js'
const PATH = '/admin/administrator'

// 管理员登陆
export const login = (data) => request.post(PATH + '/login', data)

// 验证token是否有效
export const checkAdminToken = (token) =>
  request.get(PATH + '/checkAdminToken', { params: { token } })

// 获取管理员信息
export const getAdminInfo = (id) =>
  request.get(PATH + '/getAdminInfoById', { params: { id } })

// 修改管理员信息
export const updateAdminInfo = (data) => request.put(PATH + '/update', data)

// 修改管理员状态
export const updateStatus = ({ id, status }) =>
  request.put(PATH + `/update/${id}/${status}`)

// 查询管理员列表
export const getAdminList = ({ page, pageSize, nickname }) =>
  request.get(PATH + '/pageQuery', { params: { page, pageSize, nickname } })

// 删除管理员
export const deleteByIds = (ids) =>
  request.delete(PATH + '/deleteByIds', { params: { ids: ids.join(',') } })

// 添加管理员
export const addAdmin = (data) => request.post(PATH + '/add', data)
